package com.chen.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chen.entity.Course;
import com.chen.entity.Dict;
import com.chen.mapper.CourseMapper;
import com.chen.service.ICourseService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author personcoder007
 * @since 2022-08-17
 */
@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> implements ICourseService {

    @Autowired
    private CourseMapper courseMapper;

    public IPage<Dict> selectPage(Integer pageNum, Integer pageSize, String name) {
//        创建Page对象
        IPage<Dict> page = new Page<Dict>(pageSize, pageNum);
//QueryWrapper如果name不为空进行模糊查询
        QueryWrapper queryWrapper = new QueryWrapper();
        if (!"".equals(name)) {
            queryWrapper.like("name", name);
        }

        Page<Dict> selectPage = courseMapper.selectPage(new Page<>(pageNum, pageSize), queryWrapper);
        return selectPage;

    }


}
